#ifndef INPUT_H_
#define INPUT_H_

/*
	Copyright (C) 2011 Salil Bhagurkar

	This file is part of illusion

	illusion is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as
	published by the Free Software Foundation, either version 3 of
	the License, or (at your option) any later version.

	illusion is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with illusion. 
	If not, see <http://www.gnu.org/licenses/>.
*/

//The key has the ascii of the character that was keyed in by the user.
//If the key has the 8th bit set, then the key is special and will be defined
//as below:

//Beginning of the non-ascii keys
#define KEY_NONASCII 0x100

#define KEY_ESC 0x101

#define KEY_F1 0x102
#define KEY_F2 0x103
#define KEY_F3 0x104
#define KEY_F4 0x105
#define KEY_F5 0x106
#define KEY_F6 0x107
#define KEY_F7 0x108
#define KEY_F8 0x109
#define KEY_F9 0x10a
#define KEY_F10 0x10b
#define KEY_F11 0x10c
#define KEY_F12 0x10d

#define KEY_NUM_LK 0x10e
#define KEY_SCROLL_LK 0x10f
#define KEY_PRNT_SCRN 0x110
#define KEY_SYSRQ 0x111
#define KEY_INSERT 0x112
#define KEY_PAUSE 0x113
#define KEY_DELETE 0x114
#define KEY_BREAK 0x115

#define KEY_BACKSPACE 0x116
#define KEY_TAB 0x117
#define KEY_CAPS_LK 0x118
#define KEY_LSHIFT 0x119
#define KEY_LCTRL 0x11a
#define KEY_WIN 0x11b
#define KEY_LALT 0x11c
#define KEY_SPACE 0x11d
#define KEY_RALT 0x11e
#define KEY_RCTRL 0x11f
#define KEY_MENU 0x120
#define KEY_RSHIFT 0x121
#define KEY_ENTER 0x122
#define KEY_LEFT 0x123
#define KEY_UP 0x124
#define KEY_DOWN 0x125
#define KEY_RIGHT 0x126
#define KEY_HOME 0x127
#define KEY_PGUP 0x128
#define KEY_PGDOWN 0x129
#define KEY_END 0x12a

#define KEYSTATE_DOWN 0
#define KEYSTATE_UP 1

#define INPUT_DRIVER_NAME_LEN 32



struct input_driver {
	char name[INPUT_DRIVER_NAME_LEN];
	//This should be called by the input driver once it receives a key
	int (*received_key)(struct input_driver *driver, uint_t key, uint_t state);
	struct input_driver *next, *prev;
};

void input_register_driver(struct input_driver *driver);
void input_unregister_driver(struct input_driver *driver);
int input_read_key(uint_t *key, uint_t *state);

#endif /* INPUT_H_ */
